﻿@model  RBAC.Web.Models.RoleUserModel
@using RBAC.Web.CustomHelpers
@using RBAC.Web.Mapper
@using RBAC.Web.Utilities
@{
    ViewBag.Title = "Edit RoleUser";
			string returnUrl = Url.Action("ListRoleUser", "RoleUser");
	}
@section Styles {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/form.js?3")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/jquery.multi-open-accordion.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/jquery.cookie.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/jquery.scrollabletab.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
    @*<link href="@Url.Content("~/Content/site2.css")" rel="stylesheet" type="text/css" />*@

    <script type="text/javascript">
        $(function () {
            //How to setup Datepicker
							//SetDatePicker("CreateDate", new Date(), '-71Y', 'c-70:c');
				SetDatePicker("CreateDate");
							//SetDatePicker("UpdateDate", new Date(), '-71Y', 'c-70:c');
				SetDatePicker("UpdateDate");
			            SetDatePicker("FreeDate");
			//How to setup Lookup
							SetExternalLookupFor("RoleUser_Role", "RoleUser_RoleGetExternalLookup", 
                "RoleUser_RolePopExternalLookup", 'RoleUser_Role|RoleUser_RoleLookupField|RoleRoleName');
							SetExternalLookupFor("RoleUser_User", "RoleUser_UserGetExternalLookup", 
                "RoleUser_UserPopExternalLookup", 'RoleUser_User|RoleUser_UserLookupField|UserEmail');
						//Master Detail
			 
							 
							 
							 
							 
							 
							 
							 
										        });
    </script>
}
@* RoleUser=False *@
 
<h2>RoleUser Detail</h2>
@using (Html.BeginForm("Update", "RoleUser", FormMethod.Post, new { @id = "form-RoleUser", enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(false)
    <fieldset>
        <legend>RoleUserModel</legend>

							
		<div class="two-column-container">

			@Html.HiddenFor(model => model.Id)
      					 

							  
			<div class="texteditor">
				@Html.LabelFor(model => model.Id)
				@Html.TextBoxFor(model => model.Id, new { @readonly = "readonly", @class = "txtFillNameExternal" })
											@Html.HiddenFor(model => model.Id)
						<input type="hidden" name="Mode" value="Edit" />
													<input type="hidden" name="OldValue" value="@(Model.Id == null ? "" : Model.Id +"")" />
														</div>
				

						 

			             <div class="texteditor">
                @Html.LabelFor(model => model.CreateDate)
                @Html.DatePickerFor(model => model.CreateDate, "CreateDate", false)
                            </div>


													 

			             <div class="texteditor">
                @Html.LabelFor(model => model.UpdateDate)
                @Html.DatePickerFor(model => model.UpdateDate, "UpdateDate", false)
                            </div>


						 

							 
				<div class="texteditor">
					@Html.LabelFor(model => model.UpdateBy)
					@Html.EditorFor(model => model.UpdateBy)
									</div>
																	 

						@* START ถ้าไม่มี lookup ไปหาแม่ Role, ClildClass=False, LinkToParent=False *@
						<div class="texteditor">
                @Html.LabelFor(model => model.Role)
                @Html.ExternalLookup(model => model.RoleRoleCode, "RoleUser_Role").For(model => model.Role).Render()
				            </div>
				            <div class="texteditor">
                @Html.LabelFor(model => model.RoleRoleName)
                @Html.TextBoxFor(model => model.RoleRoleName, new { @readonly = "readonly", @class = "txtFillNameExternal" })
				            </div>
				            @* END ถ้าไม่มี lookup ไปหาแม่ *@


			
						 

						@* START ถ้าไม่มี lookup ไปหาแม่ User, ClildClass=False, LinkToParent=False *@
						<div class="texteditor">
                @Html.LabelFor(model => model.User)
                @Html.ExternalLookup(model => model.UserUsername, "RoleUser_User").For(model => model.User).Render()
				            </div>
				            <div class="texteditor">
                @Html.LabelFor(model => model.UserEmail)
                @Html.TextBoxFor(model => model.UserEmail, new { @readonly = "readonly", @class = "txtFillNameExternal" })
				            </div>
				            @* END ถ้าไม่มี lookup ไปหาแม่ *@


			
													 

										<div class="texteditor">
				@Html.LabelFor(model => model.ProjectId)
                @Html.TextBoxFor(model => model.ProjectId )
							</div> @* END ไม่เป็น Attribute.Autokey *@
			

						
				</div>
		<div class="bottom-menu clear">
            <input type="button" name="btnBack" value="Cancel" id="button-back" onclick="location.href='@returnUrl'"/>
            <input type="Button" value="Save" id="button-save" onclick="JavaScript: SaveButtonClick()" />
            <input type="button" name="btnDelete" value="Delete" id="button-delete" onclick="JavaScript: DeleteButtonClick()" />
        </div>
    </fieldset>

	// Master Detail Dest Class
																	}
@* END NORMAL*@
  @* END IF For MultidimensionStyle *@

<div id="confirm-delete" title="Confirm delete." style="display: none">
    <span>Do you want to delete?</span>
</div>

<div id="confirm-save" title="Confirm save." style="display: none">
    <span>Do you want to save?</span>
</div>

<script type="text/javascript">
    function DeleteButtonClick() {
        $("#confirm-delete").dialog({
            modal:true,
            buttons: {
                Yes: function () {
                    $(this).dialog("close");
                    $.post('@Url.Action("DeleteRoleUserById", "RoleUser")',$("#form-RoleUser").serialize(),function (data) {
                        var s = '@returnUrl'
                        if(s.indexOf("?") !== -1)
                            window.location.href = s + '&result=' + data + '&operation=delete';   
                        else
                            window.location.href = s + '?result=' + data + '&operation=delete'; 
                    });
                },
                No:function(){
                    $(this).dialog("close");
                }
            }
        })
    }

    function SaveButtonClick() {
        $("#confirm-save").dialog({
            modal: true,
            buttons: {
                Yes: function () {
                    $(this).dialog("close");
                    $("#form-RoleUser").submit();
                },
                No: function () {
                    $(this).dialog("close");
                }
            }
        })
    }
</script>